<!-- 教练 – 首页 – 岗位巡查 – 新增报告			Post -->
<template>
	<view class="">
		<view class="w90 bg-fff p15 br5">
			<!-- <view class="f b c">
				<u-picker mode="time" v-model="showsc" @confirm="tom"></u-picker>
				<view class="vw45 f b c">
					<text class="fs24">选择日期</text>
					<view @click="showsc = !showsc;" v-model="arr" class="hui" style="width:160rpx;"><text >{{arr}}</text></view>
				</view>
				<view>
					<image style="width: 24rpx;height: 24rpx;" src="../../static/img/071.png" mode=""></image>
				</view>
			</view>
			<view class="f b c p_t_31">
				<view class="vw45 f b c">
					<text class="fs24">巡查地点</text>
					<input class="ipts" type="text" placeholder="地点地点地点">
				</view>
				<view>
					<image style="width: 24rpx;height: 24rpx;" src="../../static/img/071.png" mode=""></image>
				</view>
			</view>
			<view class="quanxian"></view>
			<view class="p_t_25">
				<text class="fs24 bold">岗位巡查内容岗位巡查内容岗位巡查内容</text>
			</view> -->
			<!-- <view class=""  v-if="videoSrc">
				<video :src="videoSrc" controls style="width: 100%;"></video>
			</view> -->
			<!-- <view class="mt30" >
				<image style="width: 192rpx;height: 192rpx;" src="../../static/img/072.png" mode="" @click="shangchuan_shipin"></image>
			</view> -->
			<view class="mt30">
				<u-upload @on-success="success" ref="uUpload" upload-text="上传图片" :action="action" :auto-upload="false"
					max-count="1" :show-progress="false" :source-type="type"></u-upload>
			</view>
			<view class="quanxian m_t_50"></view>
			<view class=" wd100 mt20">
				<u-field v-model="remark" label="备注:" placeholder="请填写备注"></u-field>
			</view>
			<view class="Post-but mt30">
				<button type="default" @click="tijiao">提交报告</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				action: this.$config.hosts + this.$config.UrlPostgetfile,
				videoSrc: '', // 视频资源路径
				video_tempFilePath: '', //上传视频的地址
				remark: '', //备注
				id: '',
				type:['camera']
			}
		},
		onLoad(e) {
			// 动态导航条文字
			uni.setNavigationBarTitle({
				title: '岗位巡查'
			})
			this.id = e.id
		},
		methods: {
			//提交
			tijiao() {
				this.$refs.uUpload.upload();
			},
			success(e) {
				var that = this
				var json = {
					id: that.id,
					remark: that.remark,
					img: e.data
				}
				that.$http.post(that.$config.UrlPostdoxuncha, json).then((res) => {
					if (res.status == 1) {
						that.$api.toast('提交成功')
						setTimeout(() => {
							that.$api.back()
						}, 500)
					}
				})
			},
			//上传视频
			shangchuan_video() {
				var that = this;
				uni.chooseVideo({
					count: 1, //选择多少个视频
					sourceType: ['camera'], //视频来源相册和相机都可以
					maxDuration: 60, //相机拍摄最大时长为30S
					camera: 'front', //默认摄像头是后置摄像头
					success: res => {
						console.log('打印视频');
						console.log(res);
						console.log(res.tempFilePath);
						that.videoSrc = res.tempFilePath;
						that.video_tempFilePath = res.tempFilePath;
						// uni.showLoading({
						//     title: '上传中...'
						// });
						// uni.uploadFile({
						// 	 url:that.action,
						// 	 filePath:res.tempFilePath,
						// 	 name:'file',
						// 	 formData:{
						// 		 file:res.tempFilePath,
						// 	 },
						// 	 header:{"Content-Type":"multipart/form-data"},
						// 	 success:res=>{
						// 		let data = JSON.parse(res.data)
						// 		console.log(data)
						// 		that.godaka(data.data)

						// 	 }
						// })		

						if (res.duration > '60') {
							uni.showToast({
								title: '视频不得超过1分钟,请重新选择',
								icon: 'none',
								duration: 1500
							});
						} else if (res.size > '10485760') {
							uni.showToast({
								title: '视频时长不得超过10MB,请重新选择',
								icon: 'none',
								duration: 1500
							});
						}
					},
					fail: res => {
						console.log(res)
						uni.showModal({
							content: '视频格式不正确，请重新选择',
							showCancel: false
						});
					}
				});
			},
			tom(e) {
				console.log(e);
				this.arr = e.year + '-' + e.month + '-' + e.day
			},
		}
	}
</script>

<style scoped>
	.warps {
		/* height: 200vh; */
		overflow: hidden;
		background-color: #fff;
	}

	.hui {
		width: 164rpx;
		height: 34rpx;
		font-size: 24rpx;
	}

	.ipts {
		width: 164rpx;
		height: 34rpx;
		font-size: 24rpx;
	}

	.Post-but {
		margin: 0 auto;
	}

	.Post-but>button {
		width: 502rpx;
		height: 72rpx;
		line-height: 72rpx;
		opacity: 1;
		background: #1f73f2;
		border-radius: 8rpx;
		font-size: 32rpx;
		color: #fff;
	}
</style>
